/**Hystrix+Eureka+Ribbon+OpenFeign
 * 1）依赖库：SpringCloud版本为Hoxton及以下，核心依赖为spring-cloud-starter-netflix-hystrix和spring-cloud-starter-openfeign
 *                                               spring-cloud-starter-netflix-eureka-client（含ribbon）
 * 2）main上@EnableFeignClients 注解之,并在 @FeignClient注解上添加fallback参数
 * 3）在yml中设置feign.hystrix.enabled=true以启用Hystrix，从而实现被注解接口方法调用的服务故障时的熔断、降级和隔离
 * 4）实现降级方法的FeigFallBack类，必须是实现@FeignClien注解的interface中的相关方法
 * 5）重试、限流的配置的Ribbon Demo一样
 */
package com.example.demohystrixfeignconsumer;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.Map;

@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
@EnableHystrix
@EnableHystrixDashboard
public class DemoHystrixFeignConsumerApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoHystrixFeignConsumerApplication.class, args);
    }

    @FeignClient(name="userlogin" ,fallback = FeignFallBack.class)
    public interface UserloginService{
        @RequestMapping(value = "/login",method = RequestMethod.GET)
        Map myUserlogin();
    }
}
